package afcp.alumni.action.base;

import net.sourceforge.stripes.action.RedirectResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.validation.ValidationErrorHandler;
import net.sourceforge.stripes.validation.ValidationErrors;


public abstract class EventAction extends BaseAction implements ValidationErrorHandler {

	// TODO ne pas faire de validation ici. Refondre les variables à valider
	// pour les mettre dans les PageAction d'origine. Ce qui évite les premières
	// de redirection après validation, ce que Stripes ne gère pas vraiment.
	
	/**
	 * Page where the user is coming from, in order to forward/redirect to this
	 * page after processing the request on this page.
	 * 
	 * @return
	 */
	protected abstract String fromUrl();

	@Override
	public Resolution handleValidationErrors(ValidationErrors errors)
			throws Exception {
//		return new ForwardResolution(fromUrl());
		return new RedirectResolution(fromUrl());
	}
	
	/**
	 * Convenience method.
	 * 
	 * @return A new {@link RedirectResolution} to {@link #fromUrl()}.
	 */
	protected Resolution fromRedirect() {
		return new RedirectResolution(fromUrl());
	}

}
